package WaiBao;

import java.util.Arrays;

public class ZhangWenJing {
    public static void main(String[] args) {
        String[] name = {"李花花(班长)", "王巧(副班长)", "小李(学习委员)", "郭德纲(体育委员)", "郭麒麟", "龚小刚", "邓超", "陈赫", "胡一菲", "张伟", "赵煜来", "吕子乔",
                "关谷神奇", "唐悠悠", "关于莫", "陈美嘉", "小黑", "小白", "小灰灰", "喜洋洋", "美羊羊", "沸羊羊", "村长", "灰太狼", "红太狼", "懒洋洋", "雷军", "王磊",
                "易烊千玺", "张文静(心理委员)"};//考生本人: 张文静(心理委员)
        int[] age = {19, 21, 19, 19, 19, 20, 19, 21, 19, 19, 18, 18, 18, 20, 20, 19, 18, 18, 18, 18, 19, 19, 20, 20, 20, 18, 20, 18, 20, 19};
        double[] B1 = {78, 82, 64, 90, 68, 69, 78, 89, 80, 90, 90, 87, 85, 79, 65, 68, 69, 99, 96, 88, 92, 91, 95, 85, 75, 74, 74, 74, 80, 93};
        double[] B2 = {68, 65, 69, 86, 78, 67, 88, 79, 90, 90, 90, 77, 86, 75, 65, 65, 86, 79, 66, 78, 92, 71, 95, 85, 75, 84, 84, 64, 90, 94};
        double[] B3 = {71, 96, 80, 95, 79, 69, 78, 69, 80, 60, 93, 87, 85, 75, 65, 68, 69, 69, 96, 93, 92, 81, 95, 95, 76, 84, 73, 71, 89, 94};

        double DD;//代表每个学生的总分
        double AB;//代表每个学生的平均分
//        for (int i = 0; i < 30; i++) {
//            DD = B1[i] + B2[i] + B3[i];
//            AB = (DD * 1.0) / 3;
//            System.out.println(name[i] + "的总分为:" + DD);
//            System.out.println(name[i] + "的平均分为:" + AB);
//        }


//        double res = 0, pingjun = 0;
//        double[] jieguo = new double[30];
//        for (int i = 0; i < 30; i++) {
//            res = B1[i] + B2[i] + B3[i];
//            pingjun = (res * 1.0) / 3;
//            jieguo[i] = pingjun;
//        }
//
//        for (int i = 0; i < jieguo.length - 1; i++) {
//            for (int j = 0; j < jieguo.length - i - 1; j++) {
//                if (jieguo[j] < jieguo[j + 1]) {
//                    double tep = jieguo[j];
//                    jieguo[j] = jieguo[j + 1];
//                    jieguo[j + 1] = tep;
//                }
//            }
//        }
//        System.out.println("前十名同学的成绩为:");
//        for (int i = 0; i < 10; i++) {
//            System.out.println(jieguo[i]);
//        }
//
//
//
        double p1 = 0, p2 = 0, p3 = 0;//计算每门课的平均分
        double v1 = 0, v2 = 0, v3 = 0;//计算每门课标准差
        double n1 = 0, n2 = 0, n3 = 0;//计算每门课中位数
        double he = 0;
        for (int i = 0; i < B1.length; i++) {
            he += B1[i];
        }
        p1 = (he * 1.0) / 30;
        System.out.println("生物化学的班级平均分为:" + p1);
        double Sum = 0;
        for (int i = 0; i < B2.length; i++) {
            Sum += B2[i];
        }
        p2 = (Sum * 1.0) / 30;
        System.out.println("微生物学的班级平均分为:" + p2);
        double sum = 0;
        for (int i = 0; i < B3.length; i++) {
            sum += B3[i];
        }
        p3 = (sum * 1.0) / 30;
        System.out.println("人体组织解剖学的班级平均分为:" + p3);


        double c1 = 0, c2 = 0, c3 = 0;
        for (int i = 0; i < B1.length; i++) {
            c1 += (B1[i] - p1) * (B1[i] - p1);
        }
        v1 = Math.sqrt(c1*1.0/30);
        System.out.println("生物化学的班级标准差为:" + v1);
        for (int i = 0; i < B2.length; i++) {
            c2 += (B2[i] - p2) * (B2[i] - p2);
        }
        v2 = Math.sqrt(c2*1.0/30);
        System.out.println("微生物学的班级标准差为:" + v2);

        for (int i = 0; i < B3.length; i++) {
            c3 += (B3[i] - p3) * (B3[i] - p3);
        }
        v3 = Math.sqrt(c3*1.0/30);
        System.out.println("人体组织解剖学的班级标准差为:" + v3);

        Arrays.sort(B1);
        Arrays.sort(B2);
        Arrays.sort(B3);
        n1 = (B1[15] + B2[14]) * 1.0 / 2;
        n2 = (B2[15] + B2[14]) * 1.0 / 2;
        n3 = (B3[15] + B3[14]) * 1.0 / 2;
        System.out.println("生物化学的中位数为:" + n1);
        System.out.println("微生物学的中位数为:" + n2);
        System.out.println("人体组织解剖学的中位数为:" + n3);
    }
}
